//
//  ZFFirstSubVC.m
//  PersistentPlan
//
//  Created by zhoufei on 16/4/14.
//  Copyright © 2016年 zhoufei. All rights reserved.
//
#import "ZFFirstSubVC.h"
#import <WebKit/WebKit.h>
#import "Masonry.h"
#import "UIButton+Add.h"

@interface ZFFirstSubVC ()<WKUIDelegate,WKNavigationDelegate>
@property (strong,nonatomic)WKWebView *webView;
@end

@implementation ZFFirstSubVC

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIButton *backBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setTitle:@"点击返回" forState:UIControlStateNormal];
    [backBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(backBtnAction) forControlEvents:UIControlEventTouchUpInside];
    backBtn.bounds=CGRectMake(0, 0, 100, 60);
    backBtn.center=self.view.center;
    [self.view addSubview:backBtn];
}

- (void)backBtnAction
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
}

- (void)createSubViews
{
    WKWebView *webView=[[WKWebView alloc]init];
    [self.view addSubview:webView];
    
    [webView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsZero);
    }];
    webView.allowsBackForwardNavigationGestures=YES;
    webView.navigationDelegate=self;
    webView.UIDelegate=self;
    
    self.webView=webView;
    
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]]];
    
    
}



- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler
{
    NSLog(@"navigationResponse:%@",navigationResponse);
}




@end
